import {memberInfo, getEnterpriseInfo} from "../../api/module/mine.js";
import {arrayPluck, goSwitchTab, msg, objClear, validateArray,goNav,arrayGet,pageUrl} from "../common";
import {useStore} from 'vuex';
const store = useStore()
export const jump = (userType) =>{
	let message = userType == 1?'请先实名认证':'请先认证新企业'
	msg(message)
	setTimeout(()=>{
		goNav(arrayGet(pageUrl, `realnameUrl.${userType}`))
	},1500)
}
export const authentication= async (userType) => {
	let isAuthentication = false
	if (userType == 1) {
	  await memberInfo().then(res => {
			isAuthentication = res.member_certification_status_name == "已认证"? true:false
	  }).catch(err => {
	    console.log(err)
	  })
	} else {
	  await getEnterpriseInfo().then(res => {
			isAuthentication = res.member_certification_status_name == "已认证"? true:false
	  }).catch(err => {
	    console.log(err)
	  })
	}
	if(!isAuthentication){
		jump(userType)
	}
	return isAuthentication
}